package io.daocloud.prometheustestdemo.controller;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * 测试控制器
 */
@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {
    
    private static final Logger log = LoggerFactory.getLogger(TestController.class);
    
    /**
     * 测试接口 - 用于验证限流功能
     */
    @GetMapping("/rate-limit")
    public Map<String, Object> testRateLimit() {
        log.info("Rate limit test endpoint accessed at: {}", LocalDateTime.now());
        Map<String, Object> response = new HashMap<>();
        response.put("message", "Rate limit test successful");
        response.put("timestamp", LocalDateTime.now());
        response.put("status", "OK");
        return response;
    }
    
    /**
     * 健康检查接口
     */
    @GetMapping("/health")
    public Map<String, String> health() {
        Map<String, String> response = new HashMap<>();
        response.put("status", "UP");
        response.put("service", "prometheus-test-demo");
        return response;
    }
} 